// ==UserScript==
// @name	Oracle MetaLink Search Plus
// @namespace	http://awads.net/
// @description I add links to more search options from Oracle MetaLink search results.
// @include	https://metalink.oracle.com/*
// ==/UserScript==

// Get the latest version from http://oracle-greasemonkey.googlecode.com/svn/trunk/OracleMetaLinkSearchPlus.user.js

function getOtherWebSearches(q) {
	q = escape(q);
	return '' +
	'<a target="_blank" href="http://www.oracle.com/pls/db102/print_hit_summary?search_string=' + q + '">documentation</a>, ' +
	'<a target="_blank" href="http://www.google.com/custom?cx=006891324877144204544%3Akvrje889mqc&cof=LH%3A16%3BCX%3AOracle%2520Blogs%2520Search%3BL%3Ahttp%3A%2F%2F%3BLP%3A1&client=pub-8235286535781308&q=' + q + '">blogs</a>, ' +
	'<a target="_blank" href="http://www.google.com/custom?cx=006891324877144204544%3Aqdnd3hjcj8u&cof=CX%3AOracle%2520Forums%2520Search&client=pub-8235286535781308&q=' + q + '">public forums and mailing lists</a>, ' +
	'<a target="_blank" href="http://asktom.oracle.com/pls/ask/search?p_string=' + q + '">AskTom</a>, ' +
	'<a target="_blank" href="http://search.oracle.com/search/search?tzoffset=420&default=true&start=1&nodeid=&fid=&showSimilarDoc=true&group=All&keyword=' + q + '">search.oracle.com</a>, ' +
	'<a target="_blank" href="http://www.google.com/search?q=' + q + '">Google</a> ';
}
function addOtherWebSearches() {
	var elmHeader = document.evaluate("//table[@bgcolor='#efefef']",
		document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
		null).singleNodeValue;
	if (!elmHeader) return;
	var elmq = document.getElementById('F130_P0_SRCH_TEXT');
	if (!elmq) return;
	var q = elmq.value;
	if (!q) return;
	var elmOther = document.createElement('div');
	var html = '<p style="font-size: small" align="center">Also search for <b>' + q + '</b> in: ';
	html += getOtherWebSearches(q);
	html += '</p>';
	elmOther.innerHTML = html;
	elmHeader.parentNode.insertBefore(elmOther, elmHeader.nextSibling);
}
addOtherWebSearches();